package com.wx.mall.operate.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wx.mall.operate.entity.RebMiddle;
import com.wx.mall.operate.mapper.RebMiddleMapper;
import com.wx.mall.operate.service.IRebMiddleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author j
 * @since 2020-06-07
 */
@Service
public class RebMiddleServiceImpl extends ServiceImpl<RebMiddleMapper, RebMiddle> implements IRebMiddleService {

    @Autowired
    IRebMiddleService iRebMiddleService;

    @Override
    public int deleteMid(Long ids) {
        QueryWrapper<RebMiddle> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("rebate_id",ids);
        List<RebMiddle> list = this.list(queryWrapper);
        int ar=1;
        for (RebMiddle rebMiddle:list
             ) {
            boolean b = iRebMiddleService.removeById(rebMiddle.getId());
            if (b==true){
                ar=1;
            }else {
                ar=0;
            }
        }
        return ar;
    }

}
